package com.lyf.boot.config;

import com.lyf.boot.handler.ApiVersionHandlerMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * api版本配置
 * @author Luyufan
 * @date 2023/7/10 18:34
 */
@Configuration
@ConditionalOnProperty(prefix = "api.version",value = "enabled", havingValue = "true")
@Slf4j
public class ApiVersionAutoConfig implements WebMvcRegistrations {

    @Override
    public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
        log.info("服务接口开启版本控制");
        return new ApiVersionHandlerMapping();
    }
}
